package com.tianqu.tms.www.car.controller;

import java.util.Iterator;
import java.util.List;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsController;
import com.tianqu.tms.core.base.TxController;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.exception.TmsException;
import com.tianqu.tms.core.exception.TransactionException;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.dto.TransferAcceptedInfoDto;
import com.tianqu.tms.entity.Car;
import com.tianqu.tms.www.car.actionform.CarAutoTerminalManageActionForm;

/**
 * 自助打印 - 新车上牌一览 controller
 * @author 
 */
public class CarAutoTerminalBrandNewCarListController extends TmsController {
	private Logger logger = Logger
			.getLogger(CarAutoTerminalBrandNewCarListController.class);
	public static final String PRIVILEGEDCARLIST = "privilegedCarList";

	@Override
	public void execute(UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		TxController controller = TxController.getTxController();

		// 添加事务提交异常捕获
		try {
			controller.begin();
			CarAutoTerminalManageActionForm form = (CarAutoTerminalManageActionForm) uc.getInputForm();
			Car car = Car.getInstance();
 
			List<TransferAcceptedInfoDto> list = car.loadCarAutoTerminalBrandNewCarList(form.getVin());
			Iterator<TransferAcceptedInfoDto> it = list.iterator();
			uc.setAttribute(TmsConstants.VIEWHELP, list);
			controller.commit();
		} catch (Exception e) {
			try {
				controller.rollback();
			} catch (TransactionException e1) {
				throw new TmsException(TmsException.DB_TXCRROR, e1);
			}
			// 系统异常
			if (e instanceof TmsException) {
				throw e;
			}
			throw new TmsException(TmsException.DB_TXCRROR, e);
		}

		logger.debug(this.getClass().getName() + "#execute was completed.");
		}
}
